package com.barunsw.bwf.neoarena_erp.customer_account;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.barunsw.bwf.neoarena_erp.vo.CustomerAccountVo;

/**
 * Handles requests for the application home page.
 */
@Controller
@RequestMapping("/customer")
public class CustomerAccountController {
	private static final Logger logger = LoggerFactory.getLogger(CustomerAccountController.class);
	
	@Autowired
	CustomerAccountService customerAccountService;
	
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public @ResponseBody List<CustomerAccountVo> list(
			@RequestBody @RequestParam(value="bizType", required=false) String bizType,
			@RequestBody @RequestParam(value="upCustId", required=false) String upCustId,
			@RequestBody @RequestParam(value="useYn", required=false) String useYn,
			@RequestBody @RequestParam(value="custType", required=false) String custType,
			@RequestBody @RequestParam(value="word", required=false) String word
			) throws Exception {
		logger.debug(String.format("list?bizType=%s&upCustId=%s&useYn=%s&custType=%s&word=%s", bizType, upCustId, useYn, custType, word));
		
		CustomerAccountVo customerAccountVo = new CustomerAccountVo();
		customerAccountVo.setBizType(bizType);
		customerAccountVo.setUpCustAccNo(upCustId);
		customerAccountVo.setUseYn(useYn);
		customerAccountVo.setCustType(custType);
		customerAccountVo.setWord(word);
		
		List<CustomerAccountVo> customerList = customerAccountService.selectList(customerAccountVo);
		
		return customerList;
	}
}
